%%
%% This is file `glossary.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% glossary.dtx  (with options: `package')
%% Copyright (C) 2000 Nicola Talbot, all rights reserved.
%% If you modify this file, you must change its name first.
%% You are NOT ALLOWED to distribute this file alone. You are NOT
%% ALLOWED to take money for the distribution or use of either this
%% file or a changed version, except for a nominal charge for copying
%% etc.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossary}
\RequirePackage{ifthen}
\RequirePackage{keyval}
\define@key{gloss}
           {style}
           {\ifthenelse{\equal{#1}{list} \or \equal{#1}{super} \or \equal{#1}{long}}
                       {\def\gls@style{#1}}
                       {\PackageError{glossary}
                                     {Unknown glossary style '#1'}
                                     {Available styles are: list, super and long}}}

\define@key{gloss}
           {header}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}
                       {\def\gls@header{#1}}
                       {\PackageError{glossary}
                                     {Unknown glossary style '#1'}
                                     {Available styles are: none and plain}}}

\define@key{gloss}
           {border}[plain]{\ifthenelse{\equal{#1}{none} \or \equal{#1}{plain}}
                       {\def\gls@border{#1}}
                       {\PackageError{glossary}
                                     {Unknown glossary border '#1'}
                                     {Available styles are: none and plain}}}
\newcount\gls@cols
\define@key{gloss}{cols}{\gls@cols=#1\relax
\ifthenelse{\gls@cols<2 \or \gls@cols>3}
           {\PackageError{glossary}
                         {invalid number of columns}
                         {The cols option can only be 2 or 3}}
           {}}

\define@key{gloss}
           {number}
           {\ifthenelse{\equal{#1}{none}\or\equal{#1}{page}\or\equal{#1}{section}}
                       {\def\gls@number{#1}}
                       {\PackageError{glossary}
                                     {Unknown glossary number style '#1'}
                                     {Available styles are: none, page and section}}}
\def\gls@style{long}
\def\gls@header{none}
\def\gls@border{none}
\def\gls@number{page}
\gls@cols=2\relax

\DeclareOption*{\edef\@pkg@ptions{\noexpand\setkeys{gloss}{\CurrentOption}}
\ifthenelse{\equal{\CurrentOption}{}}{}{\@pkg@ptions}}

\ProcessOptions
\ifthenelse{\equal{\gls@style}{list} \and \(\not\equal{\gls@header}{none} \or \not\equal{\gls@border}{none} \or \gls@cols=3\)}
{\PackageError{glossary}{You can't have option 'style=list' in combination with any of the other options}
{The 'list' option doesn't have a header, border or number of columns option.}}
{}
\define@key{wrgloss}{name}{\def\@n@me{#1}}
\define@key{wrgloss}{description}{\def\@descr{#1}}
\define@key{wrgloss}{sort}{\def\@s@rt{#1}}
\define@key{wrgloss}{format}{\def\@f@rm@t{#1}}
\renewcommand{\@wrglossary}[1]{\relax
\def\@n@me{}\def\@descr{}\def\@s@rt{}\def\@f@rm@t{}\relax
 \setkeys{wrgloss}{#1}\relax
 \ifthenelse{\equal{\@s@rt}{}}
    {\relax
      \ifthenelse{\equal{\@f@rm@t}{}}
      {\protected@write\@glossaryfile{}{\string\glossaryentry{\@n@me @{\@n@me}\@descr\string\relax|glsnumformat}{\theglossarynum}}}
      {\protected@write\@glossaryfile{}{\string\glossaryentry{\@n@me @{\@n@me}\@descr\string\relax|\@f@rm@t}{\theglossarynum}}}\relax
    }{\relax
      \ifthenelse{\equal{\@f@rm@t}{}}
      {\protected@write\@glossaryfile{}{\string\glossaryentry{\@s@rt @{\@n@me}\@descr\string\relax|glsnumformat}{\theglossarynum}}}
      {\protected@write\@glossaryfile{}{\string\glossaryentry{\@s@rt @{\@n@me}\@descr\string\relax|\@f@rm@t}{\theglossarynum}}}\relax
    }\relax
 \endgroup\@esphack
}
\ifthenelse{\equal{\gls@number}{page}}{
   \newcommand{\theglossarynum}{\thepage}
   \newcommand{\pagecompositor}{-}
   \newcommand{\delimN}{, }
   \newcommand{\delimR}{--}
   \newcommand{\glsnumformat}[1]{#1}}
   {\ifthenelse{\equal{\gls@number}{section}}
     {\newcommand{\theglossarynum}{\thesection}
      \newcommand{\pagecompositor}{.}
      \newcommand{\delimN}{, }
      \newcommand{\delimR}{--}
      \newcommand{\glsnumformat}[1]{#1}}
     {\newcommand{\theglossarynum}{\thepage}
      \newcommand{\pagecompositor}{-}
      \newcommand{\delimN}{}
      \newcommand{\delimR}{}
      \newcommand{\glsnumformat}[1]{}}}
\newcommand\printglossary{\@input@{\jobname.gls}}
\newcommand{\glossaryname}{Glossary}
\newcommand{\entryname}{Notation}
\newcommand{\descriptionname}{Description}
\newcommand{\istfilename}{\jobname.ist}
\newenvironment{theglossary}
  {\@ifundefined{chapter}
                {\section*{\glossaryname}}
                {\chapter*{\glossaryname}}
   \glossarypreamble\@bef@reglos}
  {\@ftergl@s\glossarypostamble}

\newcommand{\glossarypreamble}{}
\newcommand{\glossarypostamble}{}

\newif\ifgloitemfirst
\newcommand{\@bef@reglos}{\global\gloitemfirsttrue\beforeglossary}
\newcommand{\@ftergl@s}{\afterglossary\global\gloitemfirstfalse}

\ifthenelse{\equal{\gls@style}{list}}
{
\newcommand{\beforeglossary}{\begin{description}}
\newcommand{\afterglossary}{\end{description}}
\newcommand{\gloskip}{\indexspace}
\newcommand{\gloitem}[1]{\item[#1]}
\newcommand{\glodelim}{, }
}{
\ifthenelse{\equal{\gls@style}{super}}{
\IfFileExists{supertab.sty}{\RequirePackage{supertab}}
{\IfFileExists{supertabular.sty}{\RequirePackage{supertabular}}
{\PackageError{glossary}{Option "super" chosen, but can't find "supertab" package}
{If you want the "super" option, you have to have the "supertab" package installed.}}}
}
{\RequirePackage{longtable}}

\newlength{\descriptionwidth}
\setlength{\descriptionwidth}{0.6\textwidth}

\ifthenelse{\equal{\gls@header}{none}}
{
   \ifthenelse{\equal{\gls@border}{none}}
              {\newcommand{\glossaryheader}{}}
              {\newcommand{\glossaryheader}{\hline }}
}
{
\ifnum\gls@cols=2\relax
   \ifthenelse{\equal{\gls@border}{none}}
              {\newcommand{\glossaryheader}
                          {\bfseries\entryname & \bfseries \descriptionname\\}}
              {\newcommand{\glossaryheader}
                          {\hline\bfseries\entryname & \bfseries\descriptionname
                           \\\hline\hline}}
\else
   \ifthenelse{\equal{\gls@border}{none}}
              {\newcommand{\glossaryheader}
                          {\bfseries\entryname & \bfseries \descriptionname & \\}}
              {\newcommand{\glossaryheader}
                          {\hline\bfseries\entryname &\bfseries\descriptionname &
                           \\\hline\hline}}
\fi
}

\ifthenelse{\equal{\gls@border}{none}}
{
\ifnum\gls@cols=2\relax
   \newcommand{\glossaryalignment}{@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}}
\else
   \newcommand{\glossaryalignment}{@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}l}
\fi

   \ifthenelse{\equal{\gls@style}{super}}{
      \newcommand{\afterglossary}{ \\\end{supertabular}}
   }
   {
      \newcommand{\afterglossary}{ \\\end{longtable}}
   }

   \newcommand{\glosstail}{}
}
{
\ifnum\gls@cols=2\relax
   \newcommand{\glossaryalignment}{|@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}|}
\else
   \newcommand{\glossaryalignment}{|@{\hspace{\tabcolsep}\bfseries}lp{\descriptionwidth}l|}
\fi

   \ifthenelse{\equal{\gls@style}{super}}{
      \newcommand{\afterglossary}{ \\\hline\end{supertabular}}
   }
   {
      \newcommand{\afterglossary}{ \\\hline\end{longtable}}
   }

   \newcommand{\glosstail}{\hline}
}

\ifthenelse{\equal{\gls@style}{super}}
{
  \newcommand{\beforeglossary}
             {\tablehead{\glossaryheader}\tabletail{\glosstail}
              \begin{supertabular}{\glossaryalignment}%
  }
}
{
  \newcommand{\beforeglossary}
             {\begin{longtable}{\glossaryalignment}
              \glossaryheader\endhead\glosstail\endfoot
  }
}

\ifnum\gls@cols=2\relax
\newcommand{\gloskip}{\ifgloitemfirst\global\gloitemfirstfalse \else\\ \fi &}
\newcommand{\glodelim}{, }
\else
\newcommand{\gloskip}{\ifgloitemfirst\global\gloitemfirstfalse \else\\ \fi & &}
\newcommand{\glodelim}{& }
\fi
\newcommand{\gloitem}[1]{\ifgloitemfirst\global\gloitemfirstfalse #1 \else \\#1 \fi &}
}

\ifthenelse{\equal{\gls@number}{none} \and \gls@cols<3}{\renewcommand{\glodelim}{}}{}
\newif\ifist
\let\noist=\istfalse
\if@filesw\isttrue\else\istfalse\fi

\newwrite\istfile
\catcode`\%11\relax
\newcommand{\writeist}{
\openout\istfile=\istfilename
\write\istfile{% makeindex style file created by LaTeX for document "\jobname" on \today}
\write\istfile{keyword "\string\\glossaryentry"}
\write\istfile{preamble "\string\\begin{theglossary}"}
\write\istfile{postamble "\string\n\string\\end{theglossary}\string\n"}
\write\istfile{group_skip "\string\\gloskip "}
\write\istfile{item_0 "\string\n\string\\gloitem "}
\write\istfile{delim_0 "\string\n\string\\glodelim "}
\write\istfile{page_compositor "\pagecompositor"}
\write\istfile{delim_n "\string\\delimN"}
\write\istfile{delim_r "\string\\delimR"}
\closeout\istfile
}
\catcode`\%14\relax
\renewcommand{\makeglossary}{
\newwrite\@glossaryfile
\immediate\openout\@glossaryfile=\jobname.glo
\def\glossary{\@bsphack \begingroup \@sanitize \@wrglossary }
\typeout {Writing glossary file \jobname .glo }
\let \makeglossary \@empty
\ifist\writeist\fi
\noist}
\newcommand{\newglossarytype}[3]{
\@ifundefined{#1}{%
\def\@glstype{#1}\def\@glsout{#2}\def\@glsin{#3}%
\expandafter\edef\csname make\@glstype\endcsname{\noexpand\@m@kegl@ss{\@glstype}{\@glsout}}
\expandafter\edef\csname \@glstype\endcsname{\noexpand\@gl@ss@ary{\@glstype}}
\expandafter\edef\csname print\@glstype\endcsname{\noexpand\@prntgl@ss@ry{\@glsin}}
}{\PackageError{glossary}{Command \expandafter\string\csname #1\endcsname \space already defined}{%
You can't call your new glossary type '#1' because there already exists a command with this name}}
}
\newcommand\@m@kegl@ss[2]{
\expandafter\newwrite\csname @#1file\endcsname
\expandafter\immediate\expandafter\openout\csname @#1file\endcsname=\jobname.#2
\typeout {Writing #1 file \jobname .#2 }
\expandafter\let \csname make#1\endcsname \@empty
\ifist\writeist\fi
\expandafter\def\csname the#1num\endcsname{\thepage}
\noist
}
\newcommand{\@wrgl@ss@ry}[2]{\relax
\def\@n@me{}\def\@descr{}\def\@s@rt{}\def\@f@rm@t{}\relax
 \setkeys{wrgloss}{#2}\relax
 \ifthenelse{\equal{\@s@rt}{}}
    {\relax
      \ifthenelse{\equal{\@f@rm@t}{}}
      {\expandafter\protected@write\csname @#1file\endcsname{}{\string\glossaryentry{\@n@me @{\@n@me}\@descr\string\relax|glsnumformat}{\csname the#1num\endcsname}}}
      {\expandafter\protected@write\csname @#1file\endcsname{}{\string\glossaryentry{\@n@me @{\@n@me}\@descr\string\relax|\@f@rm@t}{\csname the#1num\endcsname}}}\relax
    }{\relax
      \ifthenelse{\equal{\@f@rm@t}{}}
      {\expandafter\protected@write\csname @#1file\endcsname{}{\string\glossaryentry{\@s@rt @{\@n@me}\@descr\string\relax|glsnumformat}{\csname the#1num\endcsname}}}
      {\expandafter\protected@write\csname @#1file\endcsname{}{\string\glossaryentry{\@s@rt @{\@n@me}\@descr\string\relax|\@f@rm@t}{\csname the#1num\endcsname}}}\relax
    }\relax
 \endgroup\@esphack
}
\newcommand\@gl@ss@ary[1]{\@ifundefined{@#1file}{\@bsphack\begingroup \@sanitize \@index}{\@bsphack \begingroup \@sanitize \@wrgl@ss@ry{#1}}}
\newcommand\@prntgl@ss@ry[1]{\@input@{\jobname.#1}}

\AtBeginDocument{
\renewcommand{\newglossarytype}[3]{\@latex@error{Can only be used in preamble}\@eha}}
\endinput
%%
%% End of file `glossary.sty'.
